<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common.jsp"%>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
<title>ECI_WIKI</title>

<!-- Bootstrap -->
<style type="text/css">
body {
	padding-top: 50px;
	padding-bottom: 20px;
}
</style>

</head>
<body>
	<nav class="navbar navbar-inverse navbar-fixed-top">
		<div class="container">
			<div class="navbar-header">
				<button type="button" class="navbar-toggle collapsed"
					data-toggle="collapse" data-target="#navbar" aria-expanded="false"
					aria-controls="navbar">
					<span class="sr-only">Toggle navigation</span> <span
						class="icon-bar"></span> <span class="icon-bar"></span> <span
						class="icon-bar"></span>
				</button>
				<a class="navbar-brand" href="#">ECI-WIKI</a>
			</div>
			<div id="navbar" class="navbar-collapse collapse">
				<form class="navbar-form navbar-right">
					<div class="form-group">
						<input type="text" placeholder="搜索关键字" class="form-control">
					</div>
					<button type="submit" class="btn btn-success">搜索</button>
				</form>
			</div>
			<!--/.navbar-collapse -->
		</div>
	</nav>
	<br>
	<br>
	<div class="container">
		<div class="row">
			<div class="col-md-8">
				<form class="form-horizontal" id="wikiform">
					<div class="form-group">
						<div class="col-lg-12">
							<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
							<label>新建页面</label>
						</div>
					</div>
					<div class="form-group">
						<label class="col-lg-1 control-label" for="title">标题:</label>
						<div class="col-lg-11">
							<input id="title" type="text" class="form-control" placeholder="请输入标题"	aria-describedby="titleStatus"/>
							 <span id="titleico" aria-hidden="true"></span>
							 <span id="titleStatus"	class="sr-only">(error)</span>
						</div>
					</div>
					<div class="form-group">
						<label class="col-lg-1 control-label" for="content">内容:</label>
						<div class="col-lg-11">
							<div id="content" style="display: none;"></div>
						</div>
					</div>
					<div class="form-group">
						<label class="col-lg-1 control-label" for="prepage">上级:</label>
						<div class="col-lg-11">
							<select id="parentid" class="form-control" style="width: 50%;">
								<option>1</option>
								<option>2</option>
								<option>3</option>
								<option>4</option>
								<option>5</option>
							</select>
						</div>
					</div>
					<div class="form-group">
						<div class="col-lg-12" align="right">
							<input id="saveBtn" class="btn btn-success" type="button"
								value="确认">
						</div>
					</div>
				</form>
			</div>
			<div class="col-md-2">预留</div>
		</div>


	</div>

	<hr>

	</div>
	<!-- /container -->
</body>
<script type="text/javascript">
	$(document).ready(function() {
		$('#content').summernote({
			height : 300, // set editor height
			lang : 'zh-CN',
			minHeight : null, // set minimum height of editor
			maxHeight : null, // set maximum height of editor

			focus : true
		// set focus to editable area after initializing summernote
		});
		$("#saveBtn").click(function() {
			if(validateInput()){
				$.post('<%=basePath%>/wikipages/addWiki.do',
						{title:$("#title").val(),content:$("#content").code(),parentId:$('#parentid').val()},
						function(data){
						alert(data);
				});
			}

		});
		$("#title").blur(function(){
			validateInput();
		});
	});
	
	function validateInput(){
		if($("#title").val() == '' || $.trim($("#title").val())=='' ){
			$("#wikiform > div").eq(1).addClass("form-group has-error has-feedback");
			$("#titleico").addClass("glyphicon glyphicon-remove form-control-feedback");
			//$("#title").attr("title","请输入标题");
			return false;
		}else{
			$("#wikiform > div").eq(1).removeClass().addClass("form-group has-success has-feedback");
			$("#titleico").removeClass().addClass("glyphicon glyphicon-ok form-control-feedback");
			$("#titleStatus").val().replace("error",'success');
			//$("#title").removeAttr("title");
			return true;
		}
	}
</script>
</html>